'use strict';
const {
  Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  class cookbook extends Model {
    static associate(models) {
      // define association here
    }
  };
  cookbook.init({
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: Sequelize.INTEGER,
      comment: 'id'
    },
    name: {
      type: Sequelize.STRING(100),
      allowNull: false,
      defaultValue: '',
      comment: '名称'
    },
    user_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: '发表人id'
    },
    category_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: '分类id'
    },
    description: {
      type: Sequelize.CHAR(200),
      allowNull: false,
      defaultValue: '',
      comment: '简介'
    },
    cover: {
      type: Sequelize.STRING(50),
      allowNull: false,
      defaultValue: '',
      comment: '封面'
    },
    craft_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: '食材id'
    },
    level_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: '工艺id'
    },
    taste_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: '分类id'
    },
    need_time: {
      allowNull: false,
      type: Sequelize.DATE,
      filed: 'need_at',
      comment: '所需要的时间'
    },
    ingredients: {
      type: Sequelize.STRING(50),
      allowNull: false,
      defaultValue: '',
      comment: '成分'
    },
    created_at: {
      allowNull: false,
      type: Sequelize.DATE,
      filed: 'created_at',
      comment: '创建时间'
    },
    updated_at: {
      allowNull: false,
      type: Sequelize.DATE,
      filed: 'updated_at',
      comment: '更新的时间'
    }
  }, {
    sequelize,
    modelName: 'cookbook',
    tableName: 'cookbook'
  });
  return cookbook;
};